

* INSTALL NECESSARY PACKAGES:

* ssc install blindschemes
* ssc install coefplot

capture cd "~/Replication"
use "data/V-Dem-CY-Core-v10.dta", clear

replace country_name = "Congo Kinshasa" if country_name == "Democratic Republic of the Congo"
replace country_name = "Congo Brazzaville" if country_name == "Republic of the Congo"
replace country_name = "Gambia" if country_name == "The Gambia"
replace country_name = "Sudan-North" if country_name == "Sudan"
replace country_name = "Swaziland" if country_name == "Eswatini"
replace country_name = "Cote D'Ivoire" if country_name == "Ivory Coast"

ren country_name country
merge m:1 country using "data/sub_saharan_countries.dta"

keep if _merge == 3
keep if year >= 2012

gen southafrica = country == "South Africa"
gen namibia = country == "Namibia"


gen rebellion = liberation == 0 & reb_gov == 1


est clear

loc i = 1
foreach var of varlist v2x_polyarchy v2x_ex_party v2xnp_client v2x_civlib v2x_clpol v2x_clpriv v2x_clphy {
	areg `var' reb_gov, absorb(year) vce(cluster ccode)
	
	est sto m`i'
	loc `++i'
}


set scheme plottig


coefplot (m1 m2 m3 m4 m5 m7 m6), pstyle(p1) mcol(black) keep(reb_gov) asequation ///
	yline(0, lcolor(black) lwidth(0.25)) levels(90 95) msize(2) symbol(circle) ///
ciopts(lwidth(0.8 0.3)) yscale(range(-0.4, 0.2)) ylabel(-0.4(0.2)0.2) ylabel(,labcolor(black) labsize(medsmall)) xlabel(,labcolor(black) labsize(medlarge)) ///
ytitle("Effect size", axis(1) color(black) size(medlarge)) legend(off) ///
coeflabels(, wrap(15)) ///
swapnames eqrename (m1 = "Electoral democracy" m2 = "Ruling party dimension" ///
	m3 = "Clientelism" m4 = "Civil liberties" ///
	m5 = "Civ lib: Political liberties" m6 = "Civ lib: Private liberties"  m7 = "Civ lib: Physical violence") vertical

graph display Graph, ysize(1) xsize(2)
graph export "plots/vdem.pdf", replace

